import '../model/result_model.dart';
import '../model/school_semester_model.dart';
import '../utils/request.dart';

///学校学期 API
class SchoolSemesterApi {
  SchoolSemesterApi._();

  static final _signleton = SchoolSemesterApi._();

  factory SchoolSemesterApi() => _signleton;

  ///学校学期-查询
  Future<SchoolSemesterQueryRes> query(final SchoolSemesterQueryReq req) =>
      request
          .getHandler(
            path: '/school/${req.schoolId}/semesters',
            params: req.toMap(),
          )
          .then((res) => SchoolSemesterQueryRes.fromModel(res));

  ///学校学期-保存
  Future<ResultModelRes> save(final SchoolSemesterSaveReq req) =>
      request.postHandler(
        path: '/school/${req.schoolId}/semesters',
        data: req.toMap(),
      );

  ///学校学期-删除
  Future<ResultModelRes> delete(final SchoolSemesterDeleteReq req) =>
      request.deleteHandler(
        path: '/school/${req.schoolId}/semester/${req.semesterId}',
      );
}

///学校学期 单例
final schoolSemesterApi = SchoolSemesterApi();
